﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace KAKA.Models
{
    public class LoginModel
    {
        [Required(ErrorMessage = "必填")]
        [DataType(DataType.EmailAddress)]
        [StringLength(100)]
        [RegularExpression(@"^\w+@\w+\.\w+$", ErrorMessage = "电子邮箱格式不正确")]
        [Display(Name = "电子邮箱")]
        public string Username { get; set; }

        [Required(ErrorMessage = "必填")]
        [DataType(DataType.Password)]
        [Display(Name = "密码")]
        public string Password { get; set; }

        [Display(Name = "记住我?")]
        public bool RememberMe { get; set; }
    }

    public class SignUpModel
    {
        [Required(ErrorMessage = "必填")]
        [DataType(DataType.EmailAddress)]
        [StringLength(100)]
        [RegularExpression(@"^\w+@\w+\.\w+$", ErrorMessage = "电子邮箱格式不正确")]
        [Display(Name = "电子邮箱")]
        public string Username { get; set; }

        [Required(ErrorMessage = "必填")]
        [StringLength(100, ErrorMessage = "{0}不能少于{2}个字符长度.", MinimumLength = 8)]
        [DataType(DataType.Password)]
        [Display(Name = "密码")]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "确认密码")]
        [Compare("Password", ErrorMessage = "确认密码与密码不匹配.")]
        public string RePassword { get; set; }

        [Required(ErrorMessage = "必填")]
        [Display(Name = "昵称")]
        [StringLength(15, ErrorMessage = "昵称请限制在15个字符之内。")]
        [RegularExpression(@"^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]+$", ErrorMessage = "请输入中文、英文、数字或下划线，不能以下划线开头或结尾。")]
        public string Nickname { get; set; }

        [Required(ErrorMessage = "必填")]
        [Display(Name = "性别")]
        public string Gender { get; set; }
    }

    public class ChangePasswordModel
    {
        [Required(ErrorMessage = "必填")]
        [DataType(DataType.Password)]
        [Display(Name = "旧密码")]
        public string OldPassword { get; set; }
        [Required(ErrorMessage = "必填")]
        [DataType(DataType.Password)]
        [Display(Name = "新密码")]
        public string NewPassword { get; set; }
        [Required(ErrorMessage = "必填")]
        [DataType(DataType.Password)]
        [Display(Name = "确认密码")]
        [Compare("NewPassword", ErrorMessage = "确认密码与密码不匹配.")]
        public string RePassword { get; set; }
    }

    public class ResetPasswordModel
    {
        [Required(ErrorMessage = "必填")]
        [DataType(DataType.EmailAddress)]
        [Display(Name = "电子邮箱")]
        public string Email { get; set; }
    }
}